package 网易互娱;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class test1 {
    public static void main(String[] args) throws IOException {
//        BufferedReader bf  =new BufferedReader(new InputStreamReader(System.in));
//        String s = bf.readLine();
//        String s2 = bf.readLine();
//        StringBuilder a = new StringBuilder(s);
//        StringBuilder b = new StringBuilder(s2);
//        int K = s.length();
//        int i = find(a, b,K);
//        System.out.println(i);

        String s = "1000";
        StringBuilder a = new StringBuilder(s);
        int set = set(0,'0', a, 0);
        System.out.println(set);

    }
    public static int find(StringBuilder a,StringBuilder b,int K){
        int res = 0;
        for (int i = 0; i < K-1; i++) {
            if(a.charAt(i)!=b.charAt(i)){
                res = set(i,b.charAt(i),a,res);
            }
        }
        if(a.charAt(K-1)!=b.charAt(K-1)){
            res++;
        }
        return  res;
    }


    public static int set(int index,char res,StringBuilder a,int num){
        if(index == a.length()-1){
            if(a.charAt(index)!= res){
                num++;
                a.setCharAt(index,res);
            }
            return num;
        }



        if(a.charAt(index+1) != '1'){
            set(index+1,'1',a,num);

        }

        if(index < a.length()-2){
            for (int i = index+2; i < a.length(); i++) {
                if(a.charAt(i)!='0'){
                    num = set(i,'0',a,num);
                }
            }
        }

        if(index == a.length()-2){
            if(a.charAt(index+1)!='0'){
                num++;
                a.setCharAt(index+1,'0');
            }
            num++;
            a.setCharAt(index,'0');
        }

        return num;
    }
}
